import 'package:flutter/material.dart';
import 'package:pp_uikit/theme/pp_group_theme.dart';

///
/// 自定义
///
// ignore: must_be_immutable
class PPGroupCustom extends StatefulWidget {
  /// 标题
  final Widget child;

  /// 点击回调
  final VoidCallback? onTap;

  /// 背景色
  final Color? backgroundColor;

  double? minHeight;

  /// form配置
  PPGroupTheme? themeData;

  PPGroupCustom({
    Key? key,
    required this.child,
    this.onTap,
    this.minHeight,
    this.backgroundColor,
    this.themeData,
  }) : super(key: key) {
    themeData ??= PPGroupTheme();
  }

  @override
  State<StatefulWidget> createState() {
    return PPGroupCustomState();
  }
}

class PPGroupCustomState extends State<PPGroupCustom> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      color: widget.themeData?.backgroundColor,
      padding: widget.themeData?.groupPadding,
      child: ConstrainedBox(
        constraints: BoxConstraints(
          minHeight: widget.minHeight ??= 40,
        ),
        child: GestureDetector(
          onTap: widget.onTap,
          child: widget.child,
        ),
      ),
    );
  }
}
